package com.gump.essay.demo.netty;

import java.nio.IntBuffer;

/**
 * @auther zzc
 * @date 2020/9/1 14:54
 * 概要：
 */
public class NioDemo {
    public static void main(String[] args) {
        //创建一个buffer  5个int
        IntBuffer buffer = IntBuffer.allocate(5);
        buffer.put(1);
        buffer.put(2);
        buffer.put(3);
        buffer.put(4);
        buffer.put(5);
        for (int i = 0; i < buffer.capacity(); i++) {
            buffer.put(i * 2);
        }

        //读数据
        //切换读写
        buffer.flip();

        while (buffer.hasRemaining()) {
            System.out.println(buffer.get());
        }
    }
}
